package com.ruoyi.firemen.service.impl;

import java.util.ArrayList;
import java.util.List;

import com.ruoyi.firemen.domain.FmTheoryExamScores;
import com.ruoyi.firemen.mapper.FmTEInfoMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.firemen.mapper.FmFiremenInfoMapper;
import com.ruoyi.firemen.domain.FmFiremenInfo;
import com.ruoyi.firemen.service.IFmFiremenInfoService;

/**
 * 人员信息Service业务层处理
 * 
 * @author zmc
 * @date 2024-09-23
 */
@Service
public class FmFiremenInfoServiceImpl implements IFmFiremenInfoService 
{
    @Autowired
    private FmFiremenInfoMapper fmFiremenInfoMapper;
    @Autowired
    private FmTEInfoMapper fmTEInfoMapper;



    /**
     * 查询人员信息
     * 
     * @param id 人员信息主键
     * @return 人员信息
     */
    @Override
    public FmFiremenInfo selectFmFiremenInfoById(Long id)
    {
        return fmFiremenInfoMapper.selectFmFiremenInfoById(id);
    }

    /**
     * 查询人员信息列表
     * 
     * @param fmFiremenInfo 人员信息
     * @return 人员信息
     */
    @Override
    public List<FmFiremenInfo> selectFmFiremenInfoList(FmFiremenInfo fmFiremenInfo)
    {
        return fmFiremenInfoMapper.selectFmFiremenInfoList(fmFiremenInfo);
    }
    @Override
    public  int insertAllTypeForTable(FmFiremenInfo fmFiremenInfo){
        List<FmTheoryExamScores> list = new ArrayList<FmTheoryExamScores>();
        String[] stringArray = {"政治理论","条令法纪","灭火救援实用理论","队列考核"};
        System.out.println(fmFiremenInfo.toString());
        for (int i = 0; i < 4; i++) {
            FmTheoryExamScores fmTheoryExamScores = new FmTheoryExamScores(fmFiremenInfo.getId(),stringArray[i]);
            fmTheoryExamScores.setFirefighterId(fmFiremenInfo.getId());
            list.add(fmTheoryExamScores);
        }
        if (list.size() > 0)
        {
            int i = fmTEInfoMapper.batchFmTheoryExamScores(list);
            System.out.println(i);
            return i;
        }else {
            return 0;
        }
    }
    /**
     * 新增人员信息
     * 
     * @param fmFiremenInfo 人员信息
     * @return 结果
     */
    @Override
    public int insertFmFiremenInfo(FmFiremenInfo fmFiremenInfo)
    {
//        插入各种类型的成绩
        return fmFiremenInfoMapper.insertFmFiremenInfo(fmFiremenInfo);
    }

    /**
     * 修改人员信息
     * 
     * @param fmFiremenInfo 人员信息
     * @return 结果
     */
    @Override
    public int updateFmFiremenInfo(FmFiremenInfo fmFiremenInfo)
    {
        return fmFiremenInfoMapper.updateFmFiremenInfo(fmFiremenInfo);
    }

    /**
     * 批量删除人员信息
     * 
     * @param ids 需要删除的人员信息主键
     * @return 结果
     */
    @Override
    public int deleteFmFiremenInfoByIds(Long[] ids)
    {
        return fmFiremenInfoMapper.deleteFmFiremenInfoByIds(ids);
    }

    /**
     * 删除人员信息信息
     * 
     * @param id 人员信息主键
     * @return 结果
     */
    @Override
    public int deleteFmFiremenInfoById(Long id)
    {
        return fmFiremenInfoMapper.deleteFmFiremenInfoById(id);
    }
}
